package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotEmployeePerformance;
import com.gaohe.hotal.service.IHotEmployeePerformanceService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工月绩效Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/performance")
public class HotEmployeePerformanceController extends BaseController
{
    @Autowired
    private IHotEmployeePerformanceService hotEmployeePerformanceService;

    /**
     * 查询员工月绩效列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:performance:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotEmployeePerformance hotEmployeePerformance)
    {
        startPage();
        List<HotEmployeePerformance> list = hotEmployeePerformanceService.selectHotEmployeePerformanceList(hotEmployeePerformance);
        return getDataTable(list);
    }

    /**
     * 导出员工月绩效列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:performance:export')")
    @Log(title = "员工月绩效", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotEmployeePerformance hotEmployeePerformance)
    {
        List<HotEmployeePerformance> list = hotEmployeePerformanceService.selectHotEmployeePerformanceList(hotEmployeePerformance);
        ExcelUtil<HotEmployeePerformance> util = new ExcelUtil<HotEmployeePerformance>(HotEmployeePerformance.class);
        util.exportExcel(response, list, "员工月绩效数据");
    }

    /**
     * 获取员工月绩效详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:performance:query')")
    @GetMapping(value = "/{performanceId}")
    public AjaxResult getInfo(@PathVariable("performanceId") Long performanceId)
    {
        return success(hotEmployeePerformanceService.selectHotEmployeePerformanceByPerformanceId(performanceId));
    }

    /**
     * 新增员工月绩效
     */
    @PreAuthorize("@ss.hasPermi('hotal:performance:add')")
    @Log(title = "员工月绩效", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotEmployeePerformance hotEmployeePerformance)
    {
        return toAjax(hotEmployeePerformanceService.insertHotEmployeePerformance(hotEmployeePerformance));
    }

    /**
     * 修改员工月绩效
     */
    @PreAuthorize("@ss.hasPermi('hotal:performance:edit')")
    @Log(title = "员工月绩效", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotEmployeePerformance hotEmployeePerformance)
    {
        return toAjax(hotEmployeePerformanceService.updateHotEmployeePerformance(hotEmployeePerformance));
    }

    /**
     * 删除员工月绩效
     */
    @PreAuthorize("@ss.hasPermi('hotal:performance:remove')")
    @Log(title = "员工月绩效", businessType = BusinessType.DELETE)
	@DeleteMapping("/{performanceIds}")
    public AjaxResult remove(@PathVariable Long[] performanceIds)
    {
        return toAjax(hotEmployeePerformanceService.deleteHotEmployeePerformanceByPerformanceIds(performanceIds));
    }
}
